package com.example.consumer;

import com.alibaba.dubbo.common.json.JSONObject;
import com.demo.dubbo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
    @Autowired
    private TestService testService;
/**
 * 测试json接口
 * @param name 名字
 * @return
 */
@ResponseBody
@RequestMapping("/test/{name}")
   public JSONObject TestJson(@PathVariable("name") String name){

       JSONObject jsonObject=new JSONObject();
       String str=testService.sayHello(name);
       jsonObject.put("str",str);
       return jsonObject;
   }

}
